<?php
/* @var $this StationController */
/* @var $model Station */
$alertClass = Yii::app()->basePath.'/views/calendar/confirmationAlert.php';
require_once($alertClass);
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/jquery/jquery.confirm.js"></script>
<h1>Zarządzanie stanowiskami</h1>
<div class="import">
	<div class="button">
		<?php echo CHtml::link('Dodaj nowe stanowisko', $this->createUrl('/station/create')); ?>
	</div>
</div>
<div style="clear:both;"></div>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'station-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'name',
		array(
			'class'=>'CButtonColumn',
			'buttons'=> array(
					'delete'=> array(
						'click'=>'function(event) {confirmationAlert(event, $(this).parent().parent().children(\':nth-child(1)\'));}'
					),
			),
		),
	),
)); ?>
<script type="text/javascript">
function confirmationAlert(event, element){
	event.preventDefault();
	$.confirm({
        'title'		: deleteAlert.title_begin + deleteAlert.topic_station + deleteAlert.title_end,
        'message'	: deleteAlert.message_begin + deleteAlert.topic_station + deleteAlert.message_end,
        'buttons'	: {
            'Tak'	: {
                'class'	: 'blue',
                'action': function(){
                	$.fn.yiiGridView.update('station-grid', {               		
                		type:'POST',
                		url:element['context']['href'],
                		success:function(data) {                  		
                			$.fn.yiiGridView.update('tools-grid');

                		},
                		error:function(XHR) {

                		}
                	});
                }
            },
            'Nie'	: {
                'class'	: 'gray',
                'action': function(){
                	
                    }	// Nothing to do in this case. You can as well omit the action property.
            }
        }
    });	
}

</script>